<template>
  <view class="pagebox">
    <div class="findbox">
      <div class="find">
        <img src="static/s5.png" />
        <input
          type="text"
          class="rpx28"
          confirm-type="search"
          value
          placeholder="搜索店铺名称、编号"
          placeholder-class="rpx28 col999"
        />
      </div>
    </div>
    <div style="height: 20upx;background: #F7F7F7;"></div>
    <div class="h_shop_it_box">
      <div class="h_shop_it" v-for="(item,index) in lineWorkMessage" :key="index">
        <div class="h_shop_name">
          <p class="rpx30 col666">{{item.shop_id}}</p>
          <text class="hs_n omit1 rpx28 col666">{{item.shop_name}}</text>
        </div>
        <p class="rpx26 col999">{{item.update_time}}</p>
        <navigator class="hs_but rpx26 colfff" @click="put(item)">上传</navigator>
      </div>
    </div>
  </view>
</template>

<script>
import mixins from "@/mixins";
import api from "@/mixins/api";
import ntfy from "../../components/ntfy/index.vue";
export default {
  // mixins: [mixins],
  components: { ntfy },
  data() {
    return {
	  title: "title",
    allShop:null,
    lineWorkMessage:[],
    userId:0
    };
  },
  onBackPress(options) {
    // console.log(options);
    // if (options.from === "navigateBack") {
    //   return true;
    // }
    // this.back();
    // return true;
  },
  onLoad(e) {
    let _that = this;
	  uni.getStorage({
		  key: "allShop",
		  success:res => {
        _that.allShop = res.data;
        getLineWork();
		  }
    })
    //获取user_id
    uni.getStorage({
      key:'userInfo',
      success:res=>{
        _that.userId = res.data.user_id
      }
    })
    //获取离线文件
    function getLineWork(){
      _that.allShop.forEach(element => {
        let id = element.shop_id;
        uni.getStorage({
          key:'shopId-'+id,
          success:res=>{
            res.data.shop_id = element.shop_id;
            res.data.shop_name = element.shop_name;
            res.data.update_time = element.update_time;
            _that.lineWorkMessage.push(res.data)
          }
        })
      });
    }
  },
  methods: {
    put(data){
      let putdata = mixins.putData(data,this.userId)
      api.setQuesionts(putdata, function(res) {
        console.log(res)
      })
    }
  }
};
</script>

<style scoped>
page {
  background: #fff;
}
.findbox {
  height: 100upx;
  display: flex;
  justify-content: center;
  align-items: center;
}
.find {
  display: flex;
  align-items: center;
  width: 100%;
  margin: 0 30upx;
  height: 66upx;
  background: rgba(247, 247, 247, 1);
  border-radius: 33upx;
}
.find img {
  width: 32upx;
  height: 32upx;
  display: block;
  margin: 0 20upx 0 30upx;
}
.find input {
  display: block;
  height: 66upx;
  width: 570upx;
}

.h_shop_it_box {
  padding: 25upx 0;
}
.h_shop_it {
  position: relative;
  padding: 40upx 0 30upx;
  border-bottom: 1px solid #e5e5e5;
  margin: 0 32upx;
}
.h_shop_it .hs_but {
  position: absolute;
  right: 0;
  top: 50upx;
  width: 150upx;
  text-align: center;
  height: 60upx;
  line-height: 60upx;
  background: rgba(251, 0, 26, 1);
  border-radius: 8upx;
}
.h_shop_it > p {
  height: 30upx;
  line-height: 30upx;
}
.h_shop_name {
  margin-bottom: 20upx;
  display: flex;
  align-items: center;
}
.h_shop_name > p {
  width: 100upx;
}
.h_shop_name .hs_n {
  max-width: 380upx;
}
.hs_more {
  margin: 0 8upx;
  height: 80upx;
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 1px solid #e5e5e5;
}
</style>
